package com.king.headline.base;

/**
 * Created by king on 2015/12/1.
 */

import android.view.View;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.king.headline.R;

public abstract class BaseFragment extends Fragment {
    protected Activity mActivity;

    /**
     * 获取Activity的引用
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mActivity = getActivity();// 得到的就是MainUI
        initLeft();
    }

    /**
     * 返回具体的View
     */
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = initView();
        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initData();
    }

    /**
     * 子类初始化数据
     */
    public void initData() {

    }

    /**
     * @return 让子类实现 创建自己的view
     */
    public abstract View initView();


    //------------设置title信息---------------------
    public void initLeft() {
        getImageLeft().setVisibility(View.GONE);
    }
    public ImageView getImageLeft() {
        return (ImageView) mActivity.findViewById(R.id.iv_left);
    }
}

